from selenium.webdriver import Edge
from selenium.webdriver.common import by
from selenium.webdriver.common import keys
import time

# web = Edge()
# web.get('http://lagou.com')
#
# web.find_element(by.By.XPATH,'/html/body/div[10]/div[1]/div[2]/div[2]/div[1]/div/p[1]/a').click()
# time.sleep(1)
# web.find_element(by.By.XPATH,'/html/body/div[7]/div[1]/div[1]/div[1]/form/input[1]').send_keys('python',keys.Keys.ENTER)
# time.sleep(1)
# # 窗口切换
# web.find_element(by.By.XPATH,'/html/body/div/div[1]/div/div[2]/div[3]/div/div[1]/div[1]/div[1]/div[1]/div[1]/a').click()
# time.sleep(1)
# # 注意：在selenium眼中，仍然在原来网页
# web.switch_to.window(web.window_handles[-1])
# time.sleep(2)
# # job_connect = web.find_element(by.By.XPATH,'//*[@id="job_detail"]/dd[2]').text
# # print(job_connect)
# web.close()
# # 挂掉子窗口后，仍然需要切换selenium视角
# # 此时不需要sleep等待刷新
# web.switch_to.window(web.window_handles[0])
# # print(web.find_element(by.By.XPATH,'/html/body/div/div[1]/div/div[2]/div[3]/div/div[1]/div[1]/div[1]/div[1]/div[1]/a').text)

web = Edge()
web.get('https://www.ai66.cc/e/DownSys/play/?classid=20&id=18997&pathid1=0&bf=0')
# selenium无法直接取到iframe的内容，需要先拿到iframe，然后切换视角处理
time.sleep(3)
iframe = web.find_element(by.By.XPATH,'/html/body/div[4]/div[3]/div/div/div[1]/div/iframe')
web.switch_to.frame(iframe)
# web.switch_to.default_content() # 切回默认页面
web.find_element(by.By.XPATH,"/html/body/div[4]/div[2]/video")